<#compress>
<!DOCTYPE html>
<html>
<head>
    <#include "plat/include.ftl"/>
    <style>
        .table>thead>tr>th, .table>tbody>tr>th, .table>tfoot>tr>th, .table>thead>tr>td, .table>tbody>tr>td, .table>tfoot>tr>td{
            padding: 4px;
        }
        input:read-only{
            background-color:#f1f1f1;
        }

        input{
            border: 1px solid #c1c1c1;
        }
        select:disabled{
            background-color: #f1f1f1;
        }
    </style>
    <script type="text/javascript" src="${base}/js/plugins/buttons/spin.min.js"></script>
    <script type="text/javascript" src="${base}/js/plugins/buttons/ladda.min.js"></script>
</head>
<body style="background: white">
<div class="panel panel-flat">
    <form id="optForm" class="form-horizontal">
        <table class="table table-bordered" style="max-width: 600px;margin: 0 auto">
            <tr>
                <th>操作员代码*：</th>
                <td class="form-group">
                    <input ${command?exists?string('readonly="readonly"','')} autocomplete="off" check="notnull" type="text" id="opercode" value="${command.opercode}" name="opercode" size="30"/>
                </td>
            </tr>
            <tr>
                <th>操作员姓名*：</th>
                <td class="form-group">
                    <input autocomplete="off" check="notnull" type="text" id="opername" value="${command.opername}" name="opername" size="30"/>
                </td>
            </tr>

            <#if !command?exists>
                <tr>
                    <th>登录密码：</th>
                    <td>
                        <input  autocomplete="off" placeholder="不填使用默认密码，默认888888" type="password" id="operpin" name="operpin" size="30"/>
                    </td>
                </tr>
                <tr>
                    <th>确认密码：</th>
                    <td>
                        <input  autocomplete="off" placeholder="不填使用默认密码，默认888888" type="password" id="operpin1" name="operpin1" size="30"/>
                    </td>
                </tr>
            </#if>

            <tr>
                <th>是否启用*：</th>
                <td>
                    <select id="flag" name="flag"  style="width: 221px">
                        <option ${(command.flag[0]=='1')?string('selected="selected"','')} value="1">是</option>
                        <option ${(command.flag[0]=='0')?string('selected="selected"','')} value="0">否</option>
                    </select>
                </td>
            </tr>

            <tr>
                <th>描述：</th>
                <td>
                    <textarea class="form-control" id="remark" name="remark">${command.remark}</textarea>
                </td>
            </tr>
        </table>
        <div style="text-align: center;margin-bottom: 10px;margin-top: 10px">
            <button style="width: 120px" type="button" onclick="save()" class="btn btn-primary btn-ladda btn-ladda-spinner" data-style="expand-right" data-spinner-color="#333" data-spinner-size="20">提交</button>
        </div>
    </form>
</div>

<script>
    function save() {
        var data = checkForm($('#optForm'));
        if(data===false){
            return
        }

        if (data.operpin && (data.operpin != data.operpin1)) {
            layer.tips('两次密码输入不一致', '#operpin1', {tips: [2, '#78BA32']});
            return
        }
        var flags=data.flag + '000000000';
        var roles=[];
        data.flag=flags;
        data.roles=roles.join(",");
        var l = Ladda.create( document.querySelector( '.btn-ladda-spinner' ) );
        l.start();
        post('pl/operator/save', data, function (result) {
            if (result.code == 0) {
                parent.table.ajax.reload();
                dialogClose();
            } else {
                alertError(result.message);
            }
            l.stop();
        });

    }
</script>

</body>
</html>
</#compress>